package com.lovo.bbs.bo;

import java.sql.SQLException;

import javax.naming.NamingException;

import com.lovo.bbs.dao.RegisterDao;
import com.lovo.bbs.po.RegisterPo;
import com.lovo.bbs.vo.RegisterVo;

/**
 * 注册Bo
 * @author tiancen2001
 *
 */
public class RegisterBo {
/**
 * 添加用户
 * @param registerVo
 * @return 1:注册成功, 0:用户已存在, -1:异常
 */
	public  int addUser(RegisterVo registerVo) {
		RegisterPo registerPo=new  RegisterPo();
		
		registerPo.setUsername(registerVo.getUsername());
		registerPo.setPassword(registerVo.getPassword());
		registerPo.setEmail(registerVo.getEmail());
		
		registerPo.setBirthday(registerVo.getBirthday());
		registerPo.setBlog(registerVo.getBlog());
		registerPo.setHome(registerVo.getHome());
		registerPo.setMsn(registerVo.getMsn());
		registerPo.setQq(registerVo.getQq());
		registerPo.setHomePage(registerVo.getHomePage());
		
		int added=1;
		try {
			added = new RegisterDao().addUser(registerPo);
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			added=-1;//出现异常
			e.printStackTrace();
		};
		return added;
	}

}
